package com.ct.ecommerce.idgen.dao.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.ct.ecommerce.idgen.dao.entity.SnStrategyEntity;
import java.util.List;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;


/**
 * @author changtong
 * @since 2021/5/24
 */
public interface SnStrategyMapper extends BaseMapper<SnStrategyEntity> {

    @Select("select biz_tag from ec_sn_strategy where record_status = 1")
    List<String> selectAll();

    @Update("UPDATE ec_sn_strategy SET max_id = max_id + step WHERE biz_tag = #{bizKey} ")
    void updateMaxId(@Param("bizKey") String bizKey);

    @Update("UPDATE ec_sn_strategy SET max_id = max_id + #{step} WHERE biz_tag = #{bizKey} ")
    void updateMaxIdByCustomStepAndGetLeafAlloc(@Param("bizKey")String bizKey, @Param("step")int step);
}